package Java0309;

import java.util.Scanner;

public class RmbGroup {
    public static void main(String[] args) {
        //要求：现在纸币面额有 1元，2元，5元，10元，20元，50元和100元，
        // 输入一个正整数的金额，输出所有的组成可能，比如输入 3元，则有  3个1元 和  一个2+1个1元两种可能
        //存储组合数
        int count = 0;
        Scanner scan = new Scanner(System.in);
        System.out.print("输入一个正整数金额：");
        int money = scan.nextInt();
        System.out.println("组合方式：");
        for (int i = 0; i <= money; i++) {
            for (int j = 0; j <= money / 2; j++) {
                for (int k = 0; k <= money / 5; k++) {
                    for (int x = 0; x <= money / 10; x++) {
                        for (int y = 0; y <= money / 20; y++) {
                            for (int z = 0; z <= money / 50; z++) {
                                for (int l = 0; l <= money / 100; l++) {
                                    if ((i + 2 * j + 5 * k + x * 10 + y * 20 + z * 50 + l * 100) == money) {
                                        System.out.println("1元:" + i + "张");
                                        System.out.println("2元:" + j + "张");
                                        System.out.println("5元:" + k + "张");
                                        System.out.println("10元:" + x + "张");
                                        System.out.println("20元:" + y + "张");
                                        System.out.println("50元:" + z + "张");
                                        System.out.println("100元:" + l + "张");
                                        System.out.println("*********************");
                                        count++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        System.out.println("共有" + count + "组合方式");

    }
}
